<!--
 * @Description: float2
 * @Author: rendc
 * @Date: 2022-09-22 11:17:06
 * @LastEditors: rendc
 * @LastEditTime: 2022-09-22 11:44:57
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>float2</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    .one{ 
      border: 1px solid red;
      /* 子元素都使用了浮动 父元素没有显式声明高度的情况 会失去高度 使用 overflow: hidden;清除子元素浮动对父元素的影响*/
      overflow: hidden;
    }
    .child{ 
      border: 1px solid blue;
      width: 100px;
      height: 100px;
      float: left;
    }
    .two{ 
      height: 100px;
      background-color: pink;
      clear: both;
    }
  </style>
</head>
<body>
  <div id="main">
    <div class="one">
      <div class="child"></div>
      <div class="child"></div>
      <div class="child"></div>
      <div class="child"></div>
      <div class="child"></div>
    </div>
    <div class="two"></div>
  </div>
</body>
</html>
